﻿// // ******************************************************************
// //       /\ /|       @file       TestService.cs
// //       \ V/        @brief      await29
// //       | "")       @author     Await, 285283010@qq.com
// //       /  |
// //      /  \\        @Modified   2024-12-22 17:12
// //    *(__\_\        @Copyright  Copyright (c) , 2024-12-08 10:12 Await
// // ******************************************************************

using AutomaticSubtitles.Service.Application.Translate.Service.Commands;
using AutomaticSubtitles.Service.DataAccess.Model;
using AutomaticSubtitles.Service.Infrastructure.Localization;

namespace AutomaticSubtitles.Service.Services;

public class TestService : BaseService<TestService>
{
    public async Task<ResponseModel<NormalScanVideoResult>> AddAsync(string filmPath, string mvPath, List<string> wantedExts, bool isSub)
    {
        var requiredService = GetRequiredService<ILogger<VideoListHelper>>();
        var videoListHelper = new VideoListHelper(requiredService);
        var refreshMainListAsync = await videoListHelper.RefreshMainListAsync(new List<string>() { filmPath }, new List<string>() { mvPath });

        // var tasks = new List<Task>
        // {
        //     Task.Run(async () =>
        //     {
        //         if (refreshMainListAsync.MoviesDirMap != null)
        //             foreach (var item in refreshMainListAsync.MoviesDirMap)
        //             {
        //                 var obtainVideoSubtitleFiles = await VideoListHelper.ObtainVideoSubtitleFiles(item.Value, wantedExts, isSub, true);
        //                 requiredService.LogWarning("电影字幕扫描完成" + obtainVideoSubtitleFiles?.Count);
        //             }
        //     }),
        //     Task.Run(async () =>
        //     {
        //         if (refreshMainListAsync.SeriesDirMap != null)
        //             foreach (var item in refreshMainListAsync.SeriesDirMap)
        //             {
        //                 var obtainVideoSubtitleFiles2 = await VideoListHelper.ObtainVideoSubtitleFiles(item.Value, wantedExts, isSub, false);
        //                 requiredService.LogWarning("电视剧字幕扫描完成" + obtainVideoSubtitleFiles2?.Count);
        //             }
        //     })
        // };
        // await Task.WhenAll(tasks);
        return refreshMainListAsync.CreateResult();
    }

    public async Task<ResponseModel<IEnumerable<CultureDto>>> ttttt(string path, string path2)
    {
        var localizationManager = GetService<LocalizationManager>();
        localizationManager.GetCultures();

        return localizationManager.GetCultures().CreateResult();
    }

    public async Task<string> ManualTranslation(string path, string key)
    {
        var data = new Auto_Subtitle
        {
            Name = "aaa",
            Language = "zh",
            Path = path
        };
        var startTranslationOperationCommand = new StartTranslationOperationCommand(data, key);
        await PublishAsync(startTranslationOperationCommand);
        return startTranslationOperationCommand.Result;
    }
}